package com.design.working.controller;

import com.design.working.config.BaseServlet;
import com.design.working.dto.*;
import com.design.working.dto.dept.*;
import com.design.working.service.DeptService;
import com.design.working.service.impl.DeptServiceImpl;
import com.google.gson.Gson;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 用工部门端控制器
 *
 * @author ld
 */
@WebServlet(name = "DeptController",
        urlPatterns = {"/dept/*"})
public class DeptController extends BaseServlet {

    private final DeptService deptService = new DeptServiceImpl();

    /**
     * 没有参数, "0"
     */
    private static final String NO_PARAM = "0";

    /**
     * （事务审批）查找本院学生岗位申请记录
     */
    public void selectStudentWorkApplication (HttpServletRequest request, HttpServletResponse response) throws SQLException, IOException {

        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html; charset=UTF-8");
        HttpSession session = request.getSession();
        Gson gson = new Gson();

        // 获取部门员工工号
        Integer uid = (Integer) session.getAttribute("uid");
        // 获取分页参数
        PageControlDTO pageControlDTO = new PageControlDTO();
        pageControlDTO.setPage(Integer.valueOf(request.getParameter("page")));
        pageControlDTO.setLimit(Integer.valueOf(request.getParameter("limit")));

        response.getWriter().print(gson.toJson(deptService.selectStudentWorkApplication(uid, pageControlDTO)));
    }

    /**
     * （事务审批）学生岗位申请 - 插入部门员工对学生申请记录的审批内容
     */
    public void handleStudentWorkApplication(HttpServletRequest request, HttpServletResponse response) throws IOException {

        response.setContentType("text/html; charset=UTF-8");
        request.setCharacterEncoding("UTF-8");
        HttpSession session = request.getSession();

        // 获取部门员工工号
        Integer uid = (Integer) session.getAttribute("uid");
        // 接收前端部门员工填写的审批信息
        DeptHandleStudentApplicationDTO deptHandleStudentApplicationDTO = new DeptHandleStudentApplicationDTO(
                Integer.valueOf(request.getParameter("id")),
                request.getParameter("advice"),
                Integer.valueOf(request.getParameter("operation"))
        );

        deptService.insertStudentApplicationHanding(uid, deptHandleStudentApplicationDTO);
        // 这里随意返回一个值，用于ajax的成功调用（因为那边不涉及操作返回参数）
        response.getWriter().print(1);
    }

    /**
     * （事务审批）学生岗位申请 - 查找申请表中学生申请工作填写的个人信息
     */
    public void selectStudentApplicationDetail(HttpServletRequest request, HttpServletResponse response) throws IOException, SQLException {

        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html; charset=UTF-8");
        Gson gson = new Gson();

        // 获取学生信息id
        Integer smtId = Integer.valueOf(request.getParameter("smtId"));

        response.getWriter().print(gson.toJson(deptService.selectStudentApplicationDetail(smtId)));
    }

    /**
     * （事务审批）学生岗位申请 - 查找辅导员对学生申请表的意见
     */
    public void selectStudentPreAdvice(HttpServletRequest request, HttpServletResponse response) throws IOException, SQLException {

        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html; charset=UTF-8");
        Gson gson = new Gson();

        // 获取学生申请记录id
        Integer swaId = Integer.valueOf(request.getParameter("swaId"));
        response.getWriter().print(gson.toJson(deptService.selectStudentPreAdvice(swaId)));
    }

    /**
     * （事务审批）学生岗位变动 - 查看学生岗位变动申请
     */
    public void selectStudentWorkMotion(HttpServletRequest request, HttpServletResponse response) throws IOException, SQLException {

        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html; charset=UTF-8");
        HttpSession session = request.getSession();
        Gson gson = new Gson();

        // 获取部门员工工号
        Integer uid = (Integer) session.getAttribute("uid");
        // 获取分页参数
        PageControlDTO pageControlDTO = new PageControlDTO();
        pageControlDTO.setPage(Integer.valueOf(request.getParameter("page")));
        pageControlDTO.setLimit(Integer.valueOf(request.getParameter("limit")));

        response.getWriter().print(gson.toJson(deptService.selectStudentWorkMotion(uid, pageControlDTO)));
    }

    /**
     * （事务审批）学生岗位变动 - 插入部门员工对学生岗位变更申请的审批内容
     */
    public void insertStudentMotionHanding(HttpServletRequest request, HttpServletResponse response) throws IOException, SQLException {

        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html; charset=UTF-8");
        HttpSession session = request.getSession();

        // 管理员uid
        Integer uid = (Integer) session.getAttribute("uid");

        DeptHandleStudentMotionDTO deptHandleStudentMotionDTO = new DeptHandleStudentMotionDTO();
        deptHandleStudentMotionDTO.setId(Integer.valueOf(request.getParameter("id")));
        deptHandleStudentMotionDTO.setAdvice(request.getParameter("advice"));
        deptHandleStudentMotionDTO.setOperation(Integer.valueOf(request.getParameter("operation")));

        deptService.insertStudentMotionHanding(uid, deptHandleStudentMotionDTO);
        response.getWriter().print(1);
    }

    /**
     * 查询岗位学生信息
     */
    public void selectJobStudentInfo(HttpServletRequest request, HttpServletResponse response) throws IOException {

        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/javascript; charset=UTF-8");
        HttpSession session = request.getSession();
        Gson gson = new Gson();

        // 获取辅导员工号
        Integer uid = (Integer) session.getAttribute("uid");
        // 获取分页参数
        PageControlDTO pageControlDTO = new PageControlDTO();
        pageControlDTO.setPage(Integer.valueOf(request.getParameter("page")));
        pageControlDTO.setLimit(Integer.valueOf(request.getParameter("limit")));

        response.getWriter().print(gson.toJson(deptService.selectJobStudentInfo(uid, pageControlDTO)));
    }

    /**
     * 通过学号姓名查询岗位学生信息
     */
    public void selectJobStudentInfoByName(HttpServletRequest request, HttpServletResponse response) throws IOException {

        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/javascript; charset=UTF-8");
        HttpSession session = request.getSession();
        Gson gson = new Gson();

        // 获取辅导员工号
        Integer uid = (Integer) session.getAttribute("uid");
        // 获取分页参数
        PageControlDTO pageControlDTO = new PageControlDTO();
        pageControlDTO.setPage(Integer.valueOf(request.getParameter("page")));
        pageControlDTO.setLimit(Integer.valueOf(request.getParameter("limit")));

        // 空值转换
        String stuUid = "".equals(request.getParameter("uid")) ? NO_PARAM : request.getParameter("uid");
        String studentName = request.getParameter("studentName");

        response.getWriter().print(gson.toJson(deptService.selectJobStudentInfoByName(uid, pageControlDTO, stuUid, studentName)));
    }

    /**
     * 查询学生详细信息
     */
    public void selectStudentMsg(HttpServletRequest request, HttpServletResponse response) throws IOException, SQLException {

        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/javascript; charset=UTF-8");
        Gson gson = new Gson();

        // 获取学生学号
        Integer uid = Integer.valueOf(request.getParameter("uid"));

        response.getWriter().print(gson.toJson(deptService.selectStudentMsg(uid)));
    }

    /**
     * 查询当前部门员工所属部门的学生岗位申请信息
     */
    public void selectStudentApplicationRecord(HttpServletRequest request, HttpServletResponse response) throws IOException, SQLException {

        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html; charset=UTF-8");
        HttpSession session = request.getSession();
        Gson gson = new Gson();

        // 获取辅导员工号
        Integer uid = (Integer) session.getAttribute("uid");
        // 获取分页参数
        PageControlDTO pageControlDTO = new PageControlDTO();
        pageControlDTO.setPage(Integer.valueOf(request.getParameter("page")));
        pageControlDTO.setLimit(Integer.valueOf(request.getParameter("limit")));

        response.getWriter().print(gson.toJson(deptService.selectStudentApplicationRecord(uid, pageControlDTO)));
    }

    /**
     * 通过学号姓名查询当前部门员工所属部门的学生岗位申请信息
     */
    public void selectStudentApplicationRecordByName(HttpServletRequest request, HttpServletResponse response) throws IOException {

        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html; charset=UTF-8");
        HttpSession session = request.getSession();
        Gson gson = new Gson();

        // 获取辅导员工号
        Integer uid = (Integer) session.getAttribute("uid");
        // 获取分页参数
        PageControlDTO pageControlDTO = new PageControlDTO();
        pageControlDTO.setPage(Integer.valueOf(request.getParameter("page")));
        pageControlDTO.setLimit(Integer.valueOf(request.getParameter("limit")));

        // 空值转换
        String stuUid = "".equals(request.getParameter("uid")) ? NO_PARAM : request.getParameter("uid");
        String studentName = request.getParameter("studentName");

        response.getWriter().print(gson.toJson(deptService.selectStudentApplicationRecordByName(uid, pageControlDTO, stuUid, studentName)));
    }

    /**
     * 查询学生岗位申请的记录
     */
    public void selectStuAppExamination(HttpServletRequest request, HttpServletResponse response) throws IOException, SQLException {

        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/javascript; charset=UTF-8");

        Gson gson = new Gson();

        Integer swaId = Integer.valueOf(request.getParameter("swaId"));
        response.getWriter().print(gson.toJson(deptService.selectStuAppExamination(swaId)));
    }

    /**
     * 查询当前部门领导所属部门的全部在运行岗位
     */
    public void selectDeptWorkingJob(HttpServletRequest request, HttpServletResponse response) throws IOException {

        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html; charset=UTF-8");
        HttpSession session = request.getSession();
        Gson gson = new Gson();

        // 获取辅导员工号
        Integer uid = (Integer) session.getAttribute("uid");

        // 获取分页参数
        PageControlDTO pageControlDTO = new PageControlDTO();
        pageControlDTO.setPage(Integer.valueOf(request.getParameter("page")));
        pageControlDTO.setLimit(Integer.valueOf(request.getParameter("limit")));

        response.getWriter().print(gson.toJson(deptService.selectDeptWorkingJob(uid, pageControlDTO)));
    }

    /**
     * 通过岗位名称查询当前部门领导所属部门的在运行岗位
     */
    public void selectDeptWorkingJobByName(HttpServletRequest request, HttpServletResponse response) throws IOException {

        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html; charset=UTF-8");
        HttpSession session = request.getSession();
        Gson gson = new Gson();

        // 获取辅导员工号
        Integer uid = (Integer) session.getAttribute("uid");
        // 获取分页参数
        PageControlDTO pageControlDTO = new PageControlDTO();
        pageControlDTO.setPage(Integer.valueOf(request.getParameter("page")));
        pageControlDTO.setLimit(Integer.valueOf(request.getParameter("limit")));
        // 岗位名称
        String jobName = request.getParameter("jobName");

        response.getWriter().print(gson.toJson(deptService.selectDeptWorkingJobByName(uid, pageControlDTO, jobName)));
    }

    /**
     * 插入部门领导申请删除岗位的申请数据
     */
    public void insertDeptDeleteJobMotion(HttpServletRequest request, HttpServletResponse response) throws IOException {

        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html; charset=UTF-8");
        HttpSession session = request.getSession();

        // 获取辅导员工号
        Integer uid = (Integer) session.getAttribute("uid");

        DeptDeleteJobMotionDTO deptDeleteJobMotionDTO = new DeptDeleteJobMotionDTO();
        deptDeleteJobMotionDTO.setId(Integer.valueOf(request.getParameter("id")));
        //workType默认为0（删除岗位），所以直接插入数据库，没有逻辑判断
        deptDeleteJobMotionDTO.setWorkType(Integer.valueOf(request.getParameter("workType")));
        deptDeleteJobMotionDTO.setDeptEmployeeExplanation(request.getParameter("deptExplanation"));

        deptService.insertDeptDeleteJobMotion(uid, deptDeleteJobMotionDTO);
        response.getWriter().print(1);
    }

    /**
     * 插入部门领导申请发布岗位的申请信息
     */
    public void insertDeptAddJobApplication(HttpServletRequest request, HttpServletResponse response) throws IOException {

        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html; charset=UTF-8");
        HttpSession session = request.getSession();

        // 获取辅导员工号
        Integer uid = (Integer) session.getAttribute("uid");

        DeptAddJobApplicationDTO deptAddJobApplicationDTO = new DeptAddJobApplicationDTO();
        deptAddJobApplicationDTO.setName(request.getParameter("jobName"));
        deptAddJobApplicationDTO.setJobCategory(Integer.valueOf(request.getParameter("jobCategory")));
        deptAddJobApplicationDTO.setPlace(request.getParameter("place"));
        deptAddJobApplicationDTO.setWorkDetail(request.getParameter("workDetail"));
        deptAddJobApplicationDTO.setNeedCount(Integer.valueOf(request.getParameter("needCount")));
        deptAddJobApplicationDTO.setYear(Integer.valueOf(request.getParameter("year")));
        deptAddJobApplicationDTO.setTerm(Integer.valueOf(request.getParameter("term")));

        deptService.insertDeptAddJobApplication(uid, deptAddJobApplicationDTO);
        response.getWriter().print(1);
    }

    /**
     * 查询当前部门领导的岗位申请(发布/删除)的审核信息
     */
    public void selectJobAppHandleRecord(HttpServletRequest request, HttpServletResponse response) throws IOException {

        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html; charset=UTF-8");
        HttpSession session = request.getSession();
        Gson gson = new Gson();

        // 获取辅导员工号
        Integer uid = (Integer) session.getAttribute("uid");
        // 获取分页参数
        PageControlDTO pageControlDTO = new PageControlDTO();
        pageControlDTO.setPage(Integer.valueOf(request.getParameter("page")));
        pageControlDTO.setLimit(Integer.valueOf(request.getParameter("limit")));
        //获取查询的岗位审核记录的类型（发布/删除）
        int workType = Integer.parseInt(request.getParameter("workType"));

        if (workType == 1) {
            response.getWriter().print(gson.toJson(deptService.selectAddJobAppHandleRecord(uid, pageControlDTO)));
        }
        if (workType == 0){
            response.getWriter().print(gson.toJson(deptService.selectDeleteJobAppHandleRecord(uid, pageControlDTO)));
        }
    }

    /**
     * 通过岗位名称查询当前部门领导的岗位申请(发布/删除)的审核信息
     */
    public void selectJobAppHandleRecordByName(HttpServletRequest request, HttpServletResponse response) throws IOException {

        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html; charset=UTF-8");
        HttpSession session = request.getSession();
        Gson gson = new Gson();

        // 获取辅导员工号
        Integer uid = (Integer) session.getAttribute("uid");
        // 获取分页参数
        PageControlDTO pageControlDTO = new PageControlDTO();
        pageControlDTO.setPage(Integer.valueOf(request.getParameter("page")));
        pageControlDTO.setLimit(Integer.valueOf(request.getParameter("limit")));
        // 岗位名称
        String jobName = request.getParameter("jobName");
        //获取查询的岗位审核记录的类型（发布/删除）
        int workType = Integer.parseInt(request.getParameter("workType"));

        if (workType == 1) {
            response.getWriter().print(gson.toJson(deptService.selectAddJobAppHandleRecordByName(uid, pageControlDTO, jobName)));
        }
        if (workType == 0){
            response.getWriter().print(gson.toJson(deptService.selectDeleteJobAppHandleRecordByName(uid, pageControlDTO, jobName)));
        }
    }

    /**
     * 查询当前岗位申请(发布/删除)的审批信息详情
     */
    public void selectJobAppExamination(HttpServletRequest request, HttpServletResponse response) throws IOException {

        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/javascript; charset=UTF-8");

        Gson gson = new Gson();

        //获取查询的岗位审核记录的类型（发布/删除）
        int workType = Integer.parseInt(request.getParameter("workType"));
        //获取查询的岗位审核记录的id（发布/删除）
        Integer appRecordId = Integer.valueOf(request.getParameter("appRecordId"));

        if (workType == 1) {
            response.getWriter().print(gson.toJson(deptService.selectAddJobAppExamination(appRecordId)));
        }
        if (workType == 0) {
            response.getWriter().print(gson.toJson(deptService.selectDeleteJobAppExamination(appRecordId)));
        }
    }

    /**
     * 查询当前部门员工所属部门的全部已下线岗位
     */
    public void selectDeptOfflineJob(HttpServletRequest request, HttpServletResponse response) throws IOException {

        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html; charset=UTF-8");
        HttpSession session = request.getSession();
        Gson gson = new Gson();

        // 获取辅导员工号
        Integer uid = (Integer) session.getAttribute("uid");
        // 获取分页参数
        PageControlDTO pageControlDTO = new PageControlDTO();
        pageControlDTO.setPage(Integer.valueOf(request.getParameter("page")));
        pageControlDTO.setLimit(Integer.valueOf(request.getParameter("limit")));

        response.getWriter().print(gson.toJson(deptService.selectDeptOfflineJob(uid, pageControlDTO)));
    }

    /**
     * 通过岗位名称查询当前部门员工所属部门的已下线岗位
     */
    public void selectDeptOfflineJobByName(HttpServletRequest request, HttpServletResponse response) throws IOException {

        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html; charset=UTF-8");
        HttpSession session = request.getSession();
        Gson gson = new Gson();

        // 获取辅导员工号
        Integer uid = (Integer) session.getAttribute("uid");
        // 获取分页参数
        PageControlDTO pageControlDTO = new PageControlDTO();
        pageControlDTO.setPage(Integer.valueOf(request.getParameter("page")));
        pageControlDTO.setLimit(Integer.valueOf(request.getParameter("limit")));
        //岗位名称
        String jobName = request.getParameter("jobName");

        response.getWriter().print(gson.toJson(deptService.selectDeptOfflineJobByName(uid, pageControlDTO, jobName)));
    }

    /**
     * 查询该部门已下线岗位的下线审核信息
     */
    public void selectDeptOfflineJobExamination(HttpServletRequest request, HttpServletResponse response) throws IOException {

        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/javascript; charset=UTF-8");

        Gson gson = new Gson();

        Integer jobId = Integer.valueOf(request.getParameter("jobId"));
        response.getWriter().print(gson.toJson(deptService.selectDeptOfflineJobExamination(jobId)));
    }

    /**
     * 查询目前属于在岗状态的岗位学生信息
     */
    public void selectDeptWorkingJobStudent(HttpServletRequest request, HttpServletResponse response) throws IOException {

        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html; charset=UTF-8");
        HttpSession session = request.getSession();
        Gson gson = new Gson();

        // 获取辅导员工号
        Integer uid = (Integer) session.getAttribute("uid");
        // 获取分页参数
        PageControlDTO pageControlDTO = new PageControlDTO();
        pageControlDTO.setPage(Integer.valueOf(request.getParameter("page")));
        pageControlDTO.setLimit(Integer.valueOf(request.getParameter("limit")));

        response.getWriter().print(gson.toJson(deptService.selectDeptWorkingJobStudent(uid, pageControlDTO)));
    }

    /**
     * 通过学号姓名查询目前属于在岗状态的岗位学生信息
     */
    public void selectDeptWorkingJobStudentByName(HttpServletRequest request, HttpServletResponse response) throws IOException {

        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html; charset=UTF-8");
        HttpSession session = request.getSession();
        Gson gson = new Gson();

        // 获取辅导员工号
        Integer uid = (Integer) session.getAttribute("uid");
        // 获取分页参数
        PageControlDTO pageControlDTO = new PageControlDTO();
        pageControlDTO.setPage(Integer.valueOf(request.getParameter("page")));
        pageControlDTO.setLimit(Integer.valueOf(request.getParameter("limit")));

        // 空值转换
        String stuUid = "".equals(request.getParameter("uid")) ? NO_PARAM : request.getParameter("uid");
        String studentName = request.getParameter("studentName");

        response.getWriter().print(gson.toJson(deptService.selectDeptWorkingJobStudentByName(uid, pageControlDTO, stuUid, studentName)));
    }

    /**
     * 插入部门员工考勤学生岗位信息
     */
    public void insertDeptStudentAttendInfo(HttpServletRequest request, HttpServletResponse response) throws IOException {

        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html; charset=UTF-8");
        HttpSession session = request.getSession();

        // 获取辅导员工号
        Integer uid = (Integer) session.getAttribute("uid");

        // 获取当前日期
        Date date = new Date();
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        String handleDate = dateFormat.format(date);
        System.out.println(handleDate);

        DeptHandleStudentAttendDTO deptHandleStudentAttendDTO = new DeptHandleStudentAttendDTO();
        deptHandleStudentAttendDTO.setStwId(Integer.valueOf(request.getParameter("stwId")));
        deptHandleStudentAttendDTO.setIsAttend(Integer.valueOf(request.getParameter("isAttend")));
        deptHandleStudentAttendDTO.setHandleDate(handleDate);

        deptService.insertDeptStudentAttendInfo(uid, deptHandleStudentAttendDTO);
        response.getWriter().print(1);
    }

    /**
     * 查询该部门岗位的学生考勤记录
     */
    public void selectDeptStudentAttendance(HttpServletRequest request, HttpServletResponse response) throws IOException {

        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html; charset=UTF-8");
        HttpSession session = request.getSession();
        Gson gson = new Gson();

        // 获取辅导员工号
        Integer uid = (Integer) session.getAttribute("uid");
        // 获取分页参数
        PageControlDTO pageControlDTO = new PageControlDTO();
        pageControlDTO.setPage(Integer.valueOf(request.getParameter("page")));
        pageControlDTO.setLimit(Integer.valueOf(request.getParameter("limit")));

        response.getWriter().print(gson.toJson(deptService.selectDeptStudentAttendance(uid, pageControlDTO)));
    }

    /**
     * 通过条件（学号姓名时间）查询该部门岗位的学生考勤记录
     */
    public void selectDeptStudentAttendanceByLimit(HttpServletRequest request, HttpServletResponse response) throws IOException {

        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html; charset=UTF-8");
        HttpSession session = request.getSession();
        Gson gson = new Gson();

        // 获取辅导员工号
        Integer uid = (Integer) session.getAttribute("uid");
        // 获取分页参数
        PageControlDTO pageControlDTO = new PageControlDTO();
        pageControlDTO.setPage(Integer.valueOf(request.getParameter("page")));
        pageControlDTO.setLimit(Integer.valueOf(request.getParameter("limit")));

        // 空值转换
        String stuUid = "".equals(request.getParameter("uid")) ? NO_PARAM : request.getParameter("uid");

        SearchDeptStudentAttendanceDTO searchDTO = new SearchDeptStudentAttendanceDTO();
        searchDTO.setId(stuUid);
        searchDTO.setName(request.getParameter("studentName"));
        searchDTO.setBeginDate(request.getParameter("beginDate"));
        searchDTO.setEndDate(request.getParameter("endDate"));

        response.getWriter().print(gson.toJson(deptService.selectDeptStudentAttendanceByLimit(uid, pageControlDTO, searchDTO)));
    }

    /**
     * 查询目前属于结岗/离岗状态的岗位学生信息
     */
    public void selectDeptEndJobStudent(HttpServletRequest request, HttpServletResponse response) throws IOException {

        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html; charset=UTF-8");
        HttpSession session = request.getSession();
        Gson gson = new Gson();

        // 获取辅导员工号
        Integer uid = (Integer) session.getAttribute("uid");
        // 获取分页参数
        PageControlDTO pageControlDTO = new PageControlDTO();
        pageControlDTO.setPage(Integer.valueOf(request.getParameter("page")));
        pageControlDTO.setLimit(Integer.valueOf(request.getParameter("limit")));

        response.getWriter().print(gson.toJson(deptService.selectDeptEndJobStudent(uid, pageControlDTO)));
    }

    /**
     * 插入部门员工对学生的用工评价
     */
    public void insertDeptEvaluateStuInfo(HttpServletRequest request, HttpServletResponse response) throws IOException {

        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html; charset=UTF-8");
        HttpSession session = request.getSession();

        // 获取辅导员工号
        Integer uid = (Integer) session.getAttribute("uid");

        DeptEvaluateStudentDTO deptEvaluateStudentDTO = new DeptEvaluateStudentDTO();
        deptEvaluateStudentDTO.setStwId(Integer.valueOf(request.getParameter("stwId")));
        deptEvaluateStudentDTO.setText(request.getParameter("deptEvaluation"));

        deptService.insertDeptEvaluateStuInfo(uid, deptEvaluateStudentDTO);
        response.getWriter().print(1);
    }

    /**
     * 查询历史评价记录
     */
    public void selectDeptEvaluateRecord(HttpServletRequest request, HttpServletResponse response) throws IOException {

        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html; charset=UTF-8");
        HttpSession session = request.getSession();
        Gson gson = new Gson();

        // 获取辅导员工号
        Integer uid = (Integer) session.getAttribute("uid");
        // 获取分页参数
        PageControlDTO pageControlDTO = new PageControlDTO();
        pageControlDTO.setPage(Integer.valueOf(request.getParameter("page")));
        pageControlDTO.setLimit(Integer.valueOf(request.getParameter("limit")));

        response.getWriter().print(gson.toJson(deptService.selectDeptEvaluateRecord(uid, pageControlDTO)));
    }
}
